<template>
    <div>
        <el-card v-for="(item,index) in dataList" :key="index">
            <div>
                {{item.eventName}}：
                <el-date-picker
                    v-model="item.time"
                    type="datetime"
                    placeholder="请选择"
                />
            </div>
            <el-checkbox-group v-model="item.checkValue">
                <el-checkbox v-for="check in checkList" :label="check.eventName" :value="check.eventCode" />
            </el-checkbox-group>
        </el-card>
    </div>
  </template>
  
  <script setup>
  const props = defineProps({
    dataListProps: {
        type: Object,
        default: []
    },
    checkList: {
        type: Object,
        default: [{

        }]
    }
})
  const { proxy } = getCurrentInstance();
  
  const loading = ref(true);
  let initValue={
    eventName:'止血带护理',
    time:'',
    checkValue:[]
  }
  const dataList = ref([]);
  
  if(props.dataListProps.length==0){
    dataList.value.push(initValue)
  }



  
  // 表单重置
  function reset() {
    form.value = {
      eventId: null,
      eventCode: null,
      eventName: null,
      component: null,
      eventDesc: null,
      unit: null,
      parentId: null,
      fastSort: null,
      isOnly: null,
      isQuickly: null,
      isProcess: null,
      template: null,
      status: null,
      delFlag: null,
      remark: null,
      createBy: null,
      createTime: null,
      updateBy: null,
      updateTime: null,
      processSort: null
    };
    proxy.resetForm("eventmanageRef");
  }
  
  
  /** 重置按钮操作 */
  function resetQuery() {
    proxy.resetForm("queryRef");
    handleQuery();
  }
  

  
  /** 修改按钮操作 */
  async function handleUpdate(row) {
    reset();
    await getTreeselect();
    if (row != null) {
      form.value.parentId = row.parentId;
    }
    getEventmanage(row.eventId).then(response => {
      form.value = response.data;
      open.value = true;
      title.value = "修改事件管理";
    });
  }
  
  /** 提交按钮 */
  function submitForm() {
    proxy.$refs["eventmanageRef"].validate(valid => {
      if (valid) {
        if (form.value.eventId != null) {
          updateEventmanage(form.value).then(response => {
            proxy.$modal.msgSuccess("修改成功");
            open.value = false;
            getList();
          });
        } else {
          addEventmanage(form.value).then(response => {
            proxy.$modal.msgSuccess("新增成功");
            open.value = false;
            getList();
          });
        }
      }
    });
  }
  
  /** 删除按钮操作 */
  function handleDelete(row) {
    proxy.$modal.confirm('是否确认删除事件管理编号为"' + row.eventId + '"的数据项？').then(function() {
      return delEventmanage(row.eventId);
    }).then(() => {
      getList();
      proxy.$modal.msgSuccess("删除成功");
    }).catch(() => {});
  }
  
  </script>
  